import { pget, ppostJson, post } from '@/utils/req';
import { modalApi } from '@/utils/modalReq';

// 费用立项分页
export function getTableList(data: any) {
  return pget(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/page`,
    data,
  );
}

// 费用立项不分页
export function getAllList() {
  return pget(`${modalApi.purchase}/shopec-purchase-applycost/applycost/list`);
}

// 费用立项费用项明细分页
export function getListDetailed(data: any) {
  return pget(
    `${modalApi.purchase}/shopec-purchase-costitem/costitem/list`,
    data,
  );
}

// 新增费用立项
export function addInitiation(val: any) {
  return ppostJson(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/save`,
    val,
  );
}

// 修改费用立项
export function editInitiation(id: string, data: any) {
  return ppostJson(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/update/${id}`,
    data,
  );
}

// 删除费用立项
export function deleteInitiation(data: { ids: string }) {
  return post(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/remove`,
    data,
  );
}

// 查看费用立项
export function viewInitiation(id: string) {
  return pget(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/detail/${id}`,
  );
}

/** 获取导入失败列表 */
export function getSupplierBaseExcelList(query?: any) {
  return pget(`${modalApi.purchase}/assetsaccidentdataprocessing/page`, query);
}

/** 保存费用立项导入数据 */
export function applycostImport(data?: any) {
  return ppostJson(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/import/${data.batch}`,
  );
}

// 工作流接口
/** 判断流程是否开启 */
export function getIsProcessOpen(query?: any) {
  return pget(
    `${modalApi.purchase}/shopec-purchase-utils/utils/isProcessOpen`,
    query,
  );
}
/** 流程新增 */
export function processAdd(data: any) {
  return ppostJson(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/submitFlow`,
    data,
  );
}
/** 费用立项保存 */
export function processSaveTemporary(data: any) {
  return ppostJson(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/saveTemporary`,
    data,
  );
}
// 费用立项审核
export function auditFlow(data: any) {
  return ppostJson(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/auditFlow`,
    data
  );
}
// 作废采购合同重新发起审核
export function relaunchFlow(id: any, data: any) {
  return ppostJson(
    `${modalApi.purchase}/shopec-purchase-applycost/applycost/relaunchFlow/${id}`,
    data,
  );
}
// 查看流程审核记录
export function historyList(data: any) {
  return ppostJson(`${modalApi.workflow}/process/historyList`, data);
}
